package com.itboye.sunsun.adapter;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.sunsun.R;
import com.itboye.sunsun.beans.GouWuZiXunBean.GetData.GetList;

public class GouWuZiXunAdapter extends BaseAdapter {

	ArrayList<GetList> arrayList;
	Context context;
	public GouWuZiXunAdapter(
			ArrayList<GetList> arrayList, Context context) {
		this.arrayList = arrayList;
		this.context = context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return arrayList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return arrayList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if (convertView == null) {
			holder = new Holder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.gwzx_list_item, null);
			holder.txt_content = (TextView) convertView
					.findViewById(R.id.ask_content);
			holder.txt_time = (TextView) convertView.findViewById(R.id.txt_time);
			holder.txt_reply_name = (TextView) convertView.findViewById(R.id.txt_reply_name);
			holder.txt_wy_nama = (TextView) convertView.findViewById(R.id.wx_name);
			holder.txt_reply_content = (TextView) convertView.findViewById(R.id.reply_content);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
//		XImageLoader.load(arrayList.get(position).getMainImg(), holder.img);
		holder.txt_content.setText(arrayList.get(position).getAskContent()==null?"":arrayList.get(position).getAskContent());
		holder.txt_reply_content.setText(arrayList.get(position).getReplyContent()==null?"":arrayList.get(position).getReplyContent());
		holder.txt_reply_name.setText(arrayList.get(position).getReplyUserName()==null?"":(arrayList.get(position).getReplyUserName()+"回复:"));
		holder.txt_time.setText(arrayList.get(position).getAskTime()==null?"":new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Long.parseLong(arrayList.get(position).getAskTime())*1000)));
		holder.txt_wy_nama.setText(arrayList.get(position).getAskNickname()==null?"":(arrayList.get(position).getAskNickname()));
		return convertView;
	}

	public class Holder {
		TextView txt_wy_nama, txt_time,txt_content,txt_reply_name,txt_reply_content;
	}
}
